//声明 reducer 函数
let zanReducer = (state=0, action) => {
  //根据 action 的值, 更新 state 的值
  // {type: 'add'}
  // {type: 'sub'}
  switch(action.type){
    case 'add':
      return state + 1;
    case 'sub':
      return state - 1;
    default: 
      return state;
  }
}

export default zanReducer;

//声明 action creator
export let addAction = () => {
  return {type: 'add'};
}

export let subAction = () => ({type: 'sub'});